﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/skin/default/skin.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/css/style.css" />
<title>模块菜单</title>
</head>
<body>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray"> <span class="l"> 
	<input type="hidden" value="${pid}" name="parentCode" id="parentCode"/>
	<a class="btn btn-primary radius" href="javascript:window.history.go(-1)" >返回</a>
	<a class="btn btn-primary radius" href="javascript:;" id="bindPopedom"> 绑定</a>
	</span> </div>
	<table class="table table-border table-bordered table-hover table-bg">
		<thead>
			<!-- <tr>
				<th scope="col" colspan="6">角色管理</th>
			</tr> -->
			<tr class="text-c">
				<th width="25"><input type="checkbox" id="checkAll"></th>
				<th width="80">编号</th>
				<th width="200">名称</th>
				<th width="250">链接</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${modules}" var="module" varStatus="stat">
			<tr class="text-c">
				<td><input type="checkbox" id="box_${stat.index}" value="${module.id}" name="checkModule"></td>
				<td>${module.id}</td>
				<td>${module.name}</td>
				<td>${module.url}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
</div>
<!--_footer 作为公共模版分离出去-->
<script src="${pageContext.request.contextPath}/static/js/jquery-1.11.0.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript">

$(function(){
	
	  //获取指定角色指定二级模块的拥有的权限信息
	  var operas = "${operas}";
	  
	  //获取所有的checkbox
	  var boxes = $("input[id^='box_']");
	  $.each(boxes,function(){		  
		  if(operas.indexOf(this.value)!=-1){
			  $(this).prop("checked",true).trigger("mouseover");
		  }
		  
		  //判断全选是否需要选中
		  $("#checkAll").prop("checked",boxes.length==boxes.filter(":checked").length);
	  })
	  
	  //为绑定权限按钮绑定事件
    	$("#bindPopedom").click(function(){
    		alert("111");
             //获取选中的checkbox
    		 var boxes = $("input[id^='box_']:checked");
 			 var array = new Array(); 

   			$.each(boxes,function(){
    			//将用户的id存放在数组中
    			array.push(this.value);
    		})
    		
    		window.location = "${pageContext.request.contextPath}/back/permission/bindPopedom.htm?roleId=${role.id}&id=${module.id}&operaCodes="+array.join(",");
    		
    	})
	
})

</script>
</body>
</html>